<template>

  <div class="app-container">
    <div id="divSearch" ref="divSearch">
      <el-form :inline="true" :model="Search" size="mini" class="demo-form-inline">
        <el-form-item label="输送机构: " prop="Search">
          <el-input v-model="Search.Conveyingmechanism" placeholder="输送机构" />
        </el-form-item>


        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="getDataList">查询</el-button>
          <el-button type="success" icon="el-icon-circle-plus-outline" size="mini" @click="add">新增</el-button>
        </el-form-item>
      </el-form>
    </div>

    <div style="width: 100%;">
      <el-table style="width: 100%;" :data="datalist" size="mini" border @sort-change="sortChange">
        <el-table-column align="center" label="登记表编号" width="110px" fixed>
          <template slot-scope="scope">
            {{ scope.row.CooperationAgreementNO }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="输送类别" >
          <template slot-scope="scope">
            {{ scope.row.Status==0?'发布':'作废' }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="入职人数" >
          <template slot-scope="scope">
            {{ scope.row.NumberOfEmployees }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="单位" >
          <template slot-scope="scope">
            {{ scope.row.Organizename }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="输送机构" >
          <template slot-scope="scope">
            {{ scope.row.Conveyingmechanism }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="批次">
          <template slot-scope="scope">
            {{ scope.row.Batch }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="输送期限开始">
          <template slot-scope="scope">
            {{ scope.row.StratConveyorDate }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="输送期限结束">
          <template slot-scope="scope">
            {{ scope.row.EndConveyorDate }}
          </template>
        </el-table-column>

        <el-table-column align="center" label="操作" width="150px" fixed="right">
          <template slot-scope="scope">
            <el-button type="primary" icon="el-icon-edit" circle size="small" @click="edit(scope)"></el-button>
            <el-button type="danger" icon="el-icon-delete" circle size="small" @click="delData(scope)"></el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>

  <div id="son" style="float: right;">
    <el-pagination background layout="sizes, prev, pager, next,total" :page-size="Search.pageSize" :total="Search.total"
      @current-change="pageChange" />
  </div>

  </div>






</template>

<script>
  import path from 'path'
  import { deepClone } from '@/utils'
  import { getResidentList,deleteCooperationAgreementRecord } from '@/api/resident'

  export default {

    data() {
      return {
        datalist: [],
        Search: {// 查询条件
          total: 0, // 总记录数
          pageSize: 10, // 一页显示的记录数
          page: 1, // /当前页码
          RNO: '003', // 表编号  根据Controller中对应的表编号
          jsWhere: ''// 自定义条件
        }
      }
    },
    computed: {

    },
    created() {
      this.getDataList()
    },
    methods: {
      pageChange(page) { // 翻页
        this.Search.page = page
        this.getDataList()
      },
      async getDataList() { // 获取列表数据，通用
        this.Search.DeliverType =2
        const res = await getResidentList({
          data: JSON.stringify(this.Search)
        })
        this.datalist = res.data.Table //将data 中的数据放到queueList中
        this.Search.total = res.data.Table1[0].RecordCount

      },
      add(){
        this.$router.push({
          path: '/CooperationAgreementE'
        })
      },
      async edit(scope) {
        this.$router.push({
          path: '/CooperationAgreementE',
          query: {
            JumpID: scope.row.CooperationAgreementNO
          }
        })
      },
      delData({
        $index,
        row
      }) {
        if (row.CooperationAgreementNO != undefined) {
          this.$confirm('确定删除 ' + row.CooperationAgreementNO + ' 的数据吗?', {
            confirmButtonText: '确认',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(async () => {
            await deleteCooperationAgreementRecord({
              ID: JSON.stringify(row.CooperationAgreementNO)
            })
            this.datalist.splice($index, 1)
          })

        } else {
          this.datalist.splice($index, 1);
        }
      }
    }
  }
</script>

<style>
</style>
